package cn.xy.commons.enums;

import cn.xy.commons.validator.VerifiedEnum;
import lombok.Getter;

/**
 * 数据状态枚举
 *
 *  @author xy
 */
@Getter
public enum DataStatus implements VerifiedEnum {

    /**
     * 状态类型定义
     */

    NORMAL(2, "正常"),

    DEL(3, "删除");

    /**
     * int值
     */
    private final int value;

    /**
     * 对应文本
     */
    private final String name;

    DataStatus(int value, String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 获取相反值
     *
     * @param dataStatus dataStatus
     * @return 相反值
     */
    public static int negate(int dataStatus) {
        return DEL.getValue() == dataStatus ? NORMAL.getValue() : DEL.getValue();
    }

    public static boolean isNormal(int value) {
        return value == NORMAL.value;
    }

    public static boolean isDisable(int value) {
        return !DataStatus.isNormal(value);
    }

    @Override
    public Object getVerifiedValue() {
        return this.value;
    }
}
